import java.util.Arrays;
import java.util.Comparator;

/**
 * @author LKQ
 * @date 2022/2/16 10:23
 * @description 难度中等，首先根据每个气球结束位置升序排序
 */
public class Solution {
    public static void main(String[] args) {
        int[][] points = {{-2147483646, -2147483645}, {2147483646, 2147483647}};
        Solution solution = new Solution();
        solution.findMinArrowShots(points);
    }
    public int findMinArrowShots(int[][] points) {
        if (points.length == 0) {
            return 0;
        }
        Arrays.sort(points, Comparator.comparingInt(o -> o[1]));
        int ans = 1, pre = points[0][1] , n = points.length;
        for (int i = 1; i < n; i++) {
            if (points[i][0] > pre) {
                ans++;
                pre = points[i][1];
            }
        }
        return ans;
    }
}
